package com.baseproject.datasource.get.procedure;

import com.baseproject.datasource.Repository;

import java.util.List;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by hp on 2017/8/17.
 */

public class LocalOnlyDataProcedure extends DataProcedure {

    public LocalOnlyDataProcedure(Class className) {
        super(className);
    }

    @Override
    public <T> Observable<List<T>> getList(Class<T> className) {
        return Repository.getInstance().getListFromLocalDataSource(this, this.getClassName())
                .flatMap(new Func1<List<T>, Observable<List<T>>>() {// flatMap处理嵌套RxJava请求
                    @Override
                    public Observable<List<T>> call(List<T> contentList) {
                            return Observable.just(contentList);
                    }
                });
    }
}
